﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using KNXFramework;

namespace KNXService
{
    public class KNXConnectionContainer
    {
        private static KNXConnection s_KNXConnection;
        private static ObjectController s_ObjectController;
        public static bool StartConnection()
        {
            if (s_KNXConnection == null)
            {
                s_KNXConnection = new KNXConnection("server2k8", 6720);
                s_KNXConnection.Start();
                s_ObjectController = new ObjectController(s_KNXConnection);

            }
            return true;
        }

        public static ObjectController GetController()
        {
            if (StartConnection())
                return s_ObjectController;
            else
                throw new ApplicationException("Cannot start a connection");
        }

        public static KNXConnection GetConnection()
        {
            if (StartConnection())
                return s_KNXConnection;
            else
                throw new ApplicationException("Cannot start a connection");
        }

    }
}